package com.mock.water.core.utils;

import java.util.Random;

/**
 * $$
 *
 * @author ifredomvip@gmail.com
 * @version 1.0.0
 * @date 2022/11/18 9:51
 **/
public class SaltUtils {
    public static String generateSalt(int saltLen){
        String str = "01234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz(#$^@%&*!)";
        StringBuffer salt = new StringBuffer();
        char[] chars = str.toCharArray();

        for (int i = 0; i < saltLen; i++) {
            int random = new Random().nextInt(chars.length);
            char c = chars[random];
            salt.append(c);
        }
        return salt.toString();
    }
}
